package com.studio77.guessLyric.sprite;

import android.graphics.Typeface;

import com.studio77.guessLyric.R;
import com.studio77.guessLyric.scene.GameScene;
import com.wiyun.engine.nodes.Button;
import com.wiyun.engine.nodes.Label;
import com.wiyun.engine.nodes.Node;
import com.wiyun.engine.sound.AudioManager;
import com.wiyun.engine.types.WYColor3B;

public class KeyItem extends Node {
	Button keyButton;
	Label keyLabel;

	String myKeyString;

	public KeyItem() {
		keyButton = Button.make(R.drawable.word_button_normal,
				R.drawable.word_button_normal, this, "onKeyClicked");
		this.addChild(keyButton);

		keyLabel = Label.make("", 33, Typeface.BOLD);
		keyLabel.setTouchEnabled(false);
		keyLabel.setColor(WYColor3B.make(20, 20, 20));
		this.addChild(keyLabel);
	}

	public void setKey(String key) {
		keyLabel.setText(key);
		myKeyString = key;
	}

	public void onKeyClicked() {
		// 通知控件
		AudioManager.playEffect(R.raw.enter);
		GameScene.make().getLayer().daanControl.onKeyItemClick(this, myKeyString);
	}
}
